
<%@tag import="java.util.List"%>
<%@tag import="java.util.ArrayList"%>
<%@tag import="by.epam.communalservices.entity.JkhObject"%>
<%@tag import="by.epam.communalservices.dao.jdbc.JdbcDaoJkhObject"%>
<%@tag import="java.sql.Connection"%>
<%@ attribute name="owner" %>
<%
	Connection con = (Connection) request.getSession().getAttribute("currentConnection");
	JdbcDaoJkhObject jkhObject = new JdbcDaoJkhObject(con);
	List<JkhObject> objectList = jkhObject.findAll();
	Long owner = 0L;
	try {
	    owner = Long.parseLong( getJspContext().getAttribute("owner").toString() ); 
	} catch (Exception e) {
	}
	if (owner>0) {
		List<JkhObject> newList = new ArrayList<JkhObject>();
	    for (JkhObject item : objectList) {
	        if (item.getIdOwner()==owner) {
	            newList.add(item);
	        }
	    }
		request.setAttribute("objectList", newList);
	} else {
		request.setAttribute("objectList", objectList);
	}
 %>